﻿#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    string reverseWords(string s)
    {
        int n = s.length();
        string::iterator reverse_start = s.begin();
        for (int i = 0; i < n; ++i)
        {
            if (*(s.begin() + i) == ' ')
            {
                reverse(reverse_start, s.begin() + i);
                reverse_start = s.begin() + i + 1;
            }
        }
        reverse(reverse_start, s.end());
        return s;
    }
};


